<template>
  <div class="user-center">
    <div class="sidebar">
      <ul>
        <li :class="{ active: activeSection === 'basic' }" @click="activeSection = 'basic'">
          <i class="fas fa-user"></i> 基本信息
        </li>
        <li :class="{ active: activeSection === 'credit' }" @click="activeSection = 'credit'">
          <i class="fas fa-coins"></i> 我的学分
        </li>
        <li :class="{ active: activeSection === 'course' }" @click="activeSection = 'course'">
          <i class="fas fa-book"></i> 我的课程
        </li>
        <li :class="{ active: activeSection === 'resource' }" @click="activeSection = 'resource'">
          <i class="fas fa-star"></i> 我的资源
        </li>
        <li :class="{ active: activeSection === 'setting' }" @click="activeSection = 'setting'">
          <i class="fas fa-cog"></i> 账号管理
        </li>
        <li :class="{ active: activeSection === 'history' }" @click="activeSection = 'history'">
          <i class="fas fa-history"></i> 购物记录
        </li>
       <li :class="{ active: activeSection === 'manager' }" @click="activeSection = 'manager'">
          <i class="fas fa-user-shield"></i> 管理员界面
        </li>
        <li :class="{ active: activeSection === 'auditor' }" @click="activeSection = 'auditor'">
          <i class="fas fa-user-check"></i> 审核员界面
        </li>
      </ul>
    </div>
    <div class="_main-content">
      <transition name="fade">
        <div class="main-area" :key="activeSection">
          <BasicInfo v-if="activeSection === 'basic'" />
          <MyCredit v-if="activeSection === 'credit'" />
          <MyCourse v-if="activeSection === 'course'" />
          <MyResource v-if="activeSection === 'resource'" />
          <Setting v-if="activeSection === 'setting'" />
          <ShopHistory v-if="activeSection === 'history'" />
          <CreditCertification v-if="activeSection === 'credit-certification'" /> <Manager v-if="activeSection === 'manager'" />
          <Auditor v-if="activeSection === 'auditor'" />
        </div>
      </transition>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { userManager } from '@/utils/user'
import BasicInfo from './BasicInfo.vue'
import MyCredit from './MyCredit.vue'
import MyCourse from './MyCourse.vue'
import MyResource from './UserResource.vue'
import Setting from './Setting.vue'
import ShopHistory from './ShopHistory.vue'
import CreditCertification from './CreditCertification.vue'; // 此处修改：导入 CreditCertification
import Manager from '@/system_manager/Manager.vue'; // 此处修改：导入 Manager
import Auditor from '@/auditor/Auditor.vue';         // 此处修改：导入 Auditor

const activeSection = ref('basic')
</script>

<style scoped>
.user-center {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0;
  background-color: #edfbff;
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 250px;
  background-color: #d8ecf9;
  padding: 20px 0;
  height: 100%;
  position: fixed;
  transition: transform 0.3s ease;
}

.sidebar ul {
  list-style: none;
  padding: 0;
}

.sidebar ul li {
  padding: 15px 20px;
  color: #7c2d12;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background-color 0.3s, color 0.3s;
}

.sidebar ul li:hover {
  background-color: #409EFF;
  color: #fff;
}

.sidebar ul li.active {
  background-color: #409EFF;
  color: #fff;
}

._main-content {
  margin-left: 250px;
  padding: 20px;
  width: calc(100% - 250px);
  transition: margin-left 0.3s ease;
}





.main-area {
  background-color: white;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  min-height: 400px;
  border: 1px solid #fed7aa;
}

.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.3s ease;
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .sidebar {
    width: 200px;
    transform: translateX(-200px);
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
    width: 100%;
  }
}
</style>